error when sorting a Dictionary in Python